<?php
    require_once dirname(dirname(__FILE__)) . '/shared/config/config.php';
    require_once DOCUMENT_ROOT . DIR_SHARED_LIBRARIES . 'lib_date.php';
    require_once DOCUMENT_ROOT . DIR_SHARED_LIBRARIES . 'lib_redirect.php';
    require_once DOCUMENT_ROOT . DIR_SHARED_LIBRARIES . 'lib_http.php';
    require_once DOCUMENT_ROOT . DIR_SHARED_LIBRARIES . 'lib_session.php';
    require_once DOCUMENT_ROOT . DIR_SHARED_API . 'api_country.php';
    require_once DOCUMENT_ROOT . DIR_SHARED_API . 'api_matches.php';
    require_once DOCUMENT_ROOT . DIR_SHARED_API . 'api_roulette.php';
    

    function show_datetime($date)
    {
        if (!empty($date)) {
            return lib_date::convert_to_sql_date($date, "Y-m-d H:i:s") . " - " . lib_date::convert_to_sql_time($date, "Y-m-d H:i:s");
        }
    }

    function show_match_block($item, $match_type)
    {
        ?>
        <div class="col-md-4 col-sm-6">
            <div class="service-wrapper">
                <?php
                if ($match_type == "roulette") {
                ?>
                <img src="<?php echo LINK_ROOT . DIR_SHARED_LAYOUT_IMAGES_ICONS . 'roulette.jpg' ?>" alt="Service 1">
                <?php
                } else {
                ?>
                <img src="<?php echo LINK_ROOT . DIR_SHARED_LAYOUT_IMAGES_ICONS . 'coins.png' ?>" alt="Service 1">
                <?php
                }
                ?>
                

                <h3><?php echo $item['name']; ?></h3>
                <?php
                if ($match_type !== "roulette") {
                ?>
                <p><?php echo $item['description']; ?></p>
                <?php
                }
                ?>
                <p>Start Date:
                    <b><?php echo show_datetime($item['date_start']); ?></b></p>

                <p>End Date:
                    <b class="ts-red ts-underline"><?php echo show_datetime($item['date_end']); ?></b></p>

                <p>Remaining:
                    <b class="ts-red ts-underline"><?php // echo $item['date_remaining']; ?></b></p>
                
                <?php
                if ($match_type == "roulette") {
                ?>
                <a href="roulette_detail.php?roulette_id=<?php echo $item['id']; ?>" class="btn">Detail</a>
                <?php
                } else {
                ?>
                <a href="match_detail.php?match_id=<?php echo $item['id']; ?>" class="btn">Detail</a>
                <?php
                }
                ?>
                
            </div>
        </div>
    <?php
    }

    function show_list_matches($action, $page_size, $section_id)
    {
        ?>
        <script type="text/javascript">
            function load_<?php echo $section_id; ?>_content(page) {
                $.ajax({
                    type: "POST",
                    url: "<?php echo LINK_ROOT . DIR_AJAX . $action; ?>",
                    data: "page=" + page
                        + "&page_size=<?php echo $page_size; ?>"
                        + "&section_id=<?php echo $section_id ?>",
                    success: function (result) {
                        $("#<?php echo $section_id; ?>").html(result);
                    }
                });
            }

            function apply_<?php echo $section_id; ?>_page(page) {
                load_<?php echo $section_id; ?>_content(page);
            }

            $(document).ready(function () {
                apply_<?php echo $section_id; ?>_page(1);
            });
        </script>

        <div class="section">
            <div id="<?php echo $section_id; ?>" class="container">
                <div class="row">
                    <!-- AJAX loading -->
                </div>
                <div class="ts-clear"></div>
                <div class="text-center">
                    <ul class="pagination pagination-lg">
                        <li>
                            <span onclick="apply_<?php echo $section_id; ?>_page(<?php echo $current_page - 1; ?>);">&laquo;</span>
                        </li>
                        <?php
                            if (!empty($total_page) && count($total_page) > 0) {
                                for ($page = 1; $page <= $total_page; $page++) {
                                    ?>
                                    <li
                                        <?php if ($current_page != $page) {
                                            echo 'class="active"';
                                        } ?>
                                        >
                            <span onclick="apply_<?php echo $section_id; ?>_page(<?php echo $page; ?>);">
                                <?php echo $page; ?>
                            </span>
                                    </li>
                                <?php
                                }
                            }?>
                        <li>
                            <span onclick="apply_<?php echo $section_id; ?>_page(<?php echo $current_page + 1; ?>);">&raquo;</span>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    <?php
    }

    function show_ddl_country($country_code)
    {
        $api_country = new api_country();

        $country_obj = $api_country->get_list_obj_country();
        foreach ($country_obj as $country):
            ?>
            <option value="<?php echo $country['code']; ?>"
                <?php if ($country_code === $country['code']) {
                    echo "selected";
                } ?>>
                <?php echo $country['name']; ?></option>
        <?php
        endforeach;
    }

    function show_ddl_industry($industry_id)
    {
        $list = api_matches::get_all_industries();
        foreach ($list as $item) {
            ?>
            <option value="<?php echo $item['id']; ?>"
                <?php if ($industry_id === $item['id']) {
                    echo "selected";
                } ?>>
                <?php echo $item['name']; ?></option>
        <?php
        }
    }

    function show_ddl_game($game_id)
    {
        $list = api_roulette::get_all_games();
        foreach ($list as $item) {
            ?>
            <option value="<?php echo $item['id']; ?>"
                <?php if ($game_id === $item['id']) {
                echo "selected";
                } ?>>
                <?php echo $item['name']; ?></option>
        <?php
        }
    }
    
    function show_ddl_game_choice($game_id)
    {
        $list = api_roulette::get_all_game_choices($game_id);
        foreach ($list as $item) {
            ?>
            <option value="<?php echo $item['id']; ?>">
                <?php echo $item['name']; ?></option>
        <?php
        }
    }
    
    function show_ddl_win_choice($match_id, $win_choice_id)
    {
        $list = api_matches::get_match_choices_by_match_id($match_id);
        ?>
        <option value="0">--No Select--</option>
        <?php
        foreach ($list as $item) {
            ?>
            <option value="<?php echo $item['choice_id']; ?>"
                <?php if ($win_choice_id === $item['choice_id']) {
                    echo "selected";
                } ?>>
                <?php echo $item['choice_name']; ?></option>
        <?php
        }
    }

    function show_ddl_choice($choice_text, $disabled)
    {
        $text = "";
        if (!empty($choice_text)) {
            $text = $choice_text;
        }
        ?>
        <input type="text" <?php echo $disabled; ?> class="form-control" value="<?php echo $text; ?>" name="txt_choices[]" placeholder="Put your choice here..."/>
    <?php
    }

    function show_match_status_message($is_cancel, $cancel_reason, $win_choice_id, $win_choice_message)
    {
        if (!empty($is_cancel) && $is_cancel > 0) {
            show_message("", "CANCELED: $cancel_reason", 0, 0);
        } else if (!empty($win_choice_id)) {
            show_message($win_choice_message, "", 0, 0);
        }
    }

    function show_message($success, $error, $offset, $size)
    {
        if (!empty($success)) :
            ?>
            <div class="col-md-offset-<?php echo $offset ?> col-md-<?php echo $size ?> alert alert-success"><?php echo $success; ?></div>
            <?php return TRUE;
        elseif (!empty($error)) : ?>
            <div class="col-md-offset-<?php echo $offset ?> col-md-<?php echo $size ?> alert alert-danger"><?php echo $error; ?></div>
            <?php return TRUE;
        else:
            return FALSE;
        endif;
    }

    function show_register_affiliate_form($only_for_view, $affiliate_form_id)
    {
        $disabled = "";
        if (!empty($only_for_view) && !empty($affiliate_form_id)) {
            $disabled = "disabled";
            $form = api_affiliate::get_affiliate_form_by_id($affiliate_form_id);
        }
        ?>
        
                <?php
                    //                    show_message($success_info, $error_show, 0, 0);
                ?>
                <div class="basic-login">
                    <form role="form" method="POST" action="?">
                        <input type="hidden" name="txt_aff_id" value="">

                        <div class="form-group">
                            <label><b>How will you get clients to our websites?
                                    <span style="color: red">*</span></b></label>
                            <?php
                            $text = "";
                            if (!empty($form['question_1'])) {
                                $text = $form['question_1'];
                            }
                            ?>
                            <textarea class="form-control" <?php echo $disabled; ?> name="txt_question_1" id="login-username" value="" type="text" placeholder=""><?php echo $text; ?></textarea>
                        </div>
                        <div class="form-group">
                            <label><b>Number of client expected?
                                    <span style="color: red">*</span></b></label>
                            <?php
                            $text = "";
                            if (!empty($form['question_2'])) {
                                $text = $form['question_2'];
                            }
                            ?>
                            <textarea class="form-control" <?php echo $disabled; ?> name="txt_question_2" id="login-username" value="" type="text" placeholder=""><?php echo $text; ?></textarea>
                        </div>
                        <div class="form-group">
                            <label><b>How will you promote our websites?
                                    <span style="color: red">*</span></b></label>
                            <?php
                            $text = "";
                            if (!empty($form['question_3'])) {
                                $text = $form['question_3'];
                            }
                            ?>
                            <textarea class="form-control" <?php echo $disabled; ?> name="txt_question_3" id="login-username" value="" type="text" placeholder=""><?php echo $text; ?></textarea>
                        </div>
                        <div class="form-group">
                            <label><b>What is your current job?
                                    <span style="color: red">*</span></b></label>
                            <?php
                            $text = "";
                            if (!empty($form['question_4'])) {
                                $text = $form['question_4'];
                            }
                            ?>
                            <textarea class="form-control" <?php echo $disabled; ?> name="txt_question_4" id="login-username" value="" type="text" placeholder=""><?php echo $text; ?></textarea>
                        </div>
                        <div class="form-group">
                            <label><b>You have websites? If yes, how many users do you have?
                                    <span style="color: red">*</span></b></label>
                            <?php
                            $text = "";
                            if (!empty($form['question_5'])) {
                                $text = $form['question_5'];
                            }
                            ?>
                            <textarea class="form-control" <?php echo $disabled; ?> name="txt_question_5" id="login-username" value="" type="text" placeholder=""><?php echo $text; ?></textarea>
                        </div>

                        
                        <div class="form-group">
                            <?php
                            if (empty($only_for_view)) {
                            ?>
                            <input type="submit" class="btn pull-right" value="Register" name="btn_register_affiliate"></input>
                            <?php
                            }
                            ?>
                            <div class="clearfix"></div>
                        </div>
                    </form>
                </div>
    <?php
    }

    function get_affiliate_link($user_id, $client_email)
    {
        $link = LINK_ROOT . "/register.php?aff_id=" . md5($user_id);
        if (!empty($client_email)) {
            $link .= "&register_email=" . $client_email;
        }
        return $link;
    }

    function show_affiliate_info($user, $client_list, $aff_priviledge)
    {
        ?>
        <div class="row">
            <div class="col-md-12">
                <div class="service-wrapper">
                    <div class="row">
                        <h1 class="text-left" style="float: left; clear: both; padding-left: 15px; font-size: 18pt">
                            <span class="label label-primary"> Your affiliate link is:</span>
                        </h1>
                        <span class="text-info" style="float: left; text-align: left; padding: 7px 15px;"> <?php echo get_affiliate_link($user[0], ""); ?></span>
                    </div>
                </div>

                <div class="service-wrapper">
                    <div class="row">
                        <h1 class="text-left" style="float: left; clear: both; padding-left: 15px; font-size: 18pt">
                            <span class="label label-primary"> Your affiliate code:</span>
                        </h1>
                        <span class="text-info" style="float: left; text-align: left; padding: 7px 15px;"> <?php echo md5($user[0]); ?></span>
                    </div>
                </div>

                <div class="service-wrapper">
                    <div class="row">
                        <h1><span class="label label-primary"> Client List:</span></h1>
                        <table class="table" style="margin-top: 30px">
                            <thead>
                            <tr>
                                <th class="text-center"> ID</th>
                                <th class="text-center"> Username</th>
                                <?php if ($aff_priviledge == 2) : ?>
                                    <th class="text-center"> Email</th>
                                    <th class="text-center"> Name</th>
                                    <th class="text-center"> Phone Number</th>
                                <?php endif; ?>
                                <th class="text-center"> Received Profit</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php
                                if (empty($client_list)) {
                                ?>
                                <tr>
                                    <td colspan="6">Empty</td>
                                </tr>
                            <?php
                            } else {
                                $total = 0;
                                foreach ($client_list as $client) :
                                    $total += $client['affiliate_profit'];
                                    ?>
                                    <tr>
                                        <td class="text-center"> <?php echo $client['id']; ?></td>
                                        <td class="text-center"> <?php echo $client['username']; ?></td>
                                        <?php if ($aff_priviledge == 2) : ?>
                                            <td class="text-center"> <?php echo $client['email']; ?></td>
                                            <td class="text-center"> <?php echo $client['first_name'] . ' ' . $client['last_name']; ?></td>
                                            <td class="text-center"> <?php echo $client['phone_number']; ?></td>
                                        <?php endif; ?>
                                        <td class="text-center text-success">
                                            $<?php echo $client['affiliate_profit']; ?>
                                        </td>
                                    </tr>
                                <?php endforeach; ?>

                            </tbody>
                            <tfoot>
                            <tr>
                                <th colspan="<?php echo (($aff_priviledge == 2) ? '5' : '2'); ?>"> Total Profit Received:</th>
                                <th class="text-success text-center"> $<?php echo $total; ?></th>
                            </tr>
                            </tfoot>
                            <?php } ?>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    <?php
    }

    function show_table_bet_history($list_bet_history)
    {
        ?>
        <h1 style="margin-bottom: 35px;"><span class="label label-success">Betting History</span></h1>
        <table class="table">
            <tr>
                <th class="text-center">Match Name</th>
                <th class="text-center">Choice</th>
                <th class="text-center">Date</th>
                <th class="text-center">Amount</th>
                <th class="text-center">Profit If Win</th>
                <th class="text-center">Result</th>
                <th class="text-center">Result Money</th>
            </tr>
            <?php
                if (!empty($list_bet_history)) :
                    foreach ($list_bet_history as $bet_history) :
                        $match_name   = api_matches::get_match_by_id($bet_history['match_id']);
                        $choice       = api_choice::get_by_id($bet_history['choice_id']);
                        $profit       = api_bet_calculators::calculate_profit_if_bet_win($bet_history, FALSE);
                        $result       = api_bet_history::get_result_bet_of_match($bet_history['match_id'], $bet_history['id']);
                        $result_money = api_bet_history::get_result_money($result, $bet_history['bet_amount'], $profit);
                        ?>
                        <tr>
                            <td class="text-center"><?php echo $match_name['name']; ?></td>
                            <td class="text-center"><?php echo $choice['name']; ?></td>
                            <td class="text-center"><?php echo $bet_history['bet_date']; ?></td>
                            <td class="text-center text-success">$<?php echo $bet_history['bet_amount']; ?></td>
                                <?php
                                    if ($profit > 0) {
                                ?>
                            <td class="text-center text-success">+ $<?php echo $profit; ?></td>
                            <?php
                                } else {
                                ?>
                                <td class="text-center">Not available now</td>
                            <?php
                            }
                            ?>
                            <td class="text-center"><?php echo $result; ?></td>
                            <td class="text-center <?php echo $result_money['class']; ?>"><?php echo $result_money['money_text']; ?></td>
                        </tr>
                    <?php
                    endforeach;
                else :
                    ?>
                    <tr>
                        <td colspan="6">Empty</td>
                    </tr>
                <?php
                endif;
            ?>
        </table>
    <?php
    }

    function show_table_tran_history($list_tran_history)
    {
        ?>
        <h1 style="margin-bottom: 35px;"><span class="label label-success">Transaction History</span></h1>
        <table class="table">
            <tr>
                <th class="text-center">ID</th>
                <th class="text-center">Date</th>
                <th class="text-center">Decription</th>
                <th class="text-center">Action</th>
                <th class="text-center">Amount</th>
            </tr>
            <?php
                if (!empty($list_tran_history)) :
                    foreach ($list_tran_history as $tran_history) :
                        $action = api_tran_history::get_action_name($tran_history['action_id']);
                        ?>
                        <tr>
                            <td class="text-center"><?php echo $tran_history['id']; ?></td>
                            <td class="text-center"><?php echo $tran_history['date']; ?></td>
                            <td class="text-center"><?php echo $tran_history['description']; ?></td>
                            <?php if ($tran_history['action_id'] == 3) : ?>
                                <td class="text-center text-danger"><?php echo $action ?></td>
                                <td class="text-center text-danger">- $<?php echo $tran_history['amount']; ?></td>
                            <?php elseif ($tran_history['action_id'] == 4) : ?>
                                <td class="text-center text-success"><?php echo $action ?></td>
                                <td class="text-center text-success">+ $<?php echo $tran_history['amount']; ?></td>
                            <?php endif; ?>
                        </tr>
                    <?php
                    endforeach;
                else :
                    ?>
                    <tr>
                        <td colspan="6">Empty</td>
                    </tr>
                <?php
                endif;
            ?>
        </table>
    <?php
    }
    
    function show_modal_message($message) {
    ?>
        <script>
        $(document).ready(function() {
            bootbox.alert("<?php echo $message; ?>");
        });
        </script>
    <?php
    }
    
    function show_deposit_option() {
    ?>
        <h1 style="margin-bottom: 35px;"><span class="label label-success">Deposit Money</span></h1>
        <div class="col-md-offset-1 col-md-10 gaf-container">
        <form class="form deposit_form" method="post">
        <ul class="option unstyled">
            <li id="deposit_gcList" class="selected round-top first" style=" ">

                  <div class="span1 option-radio-container">
                    <input id="deposit_gcRadio" type="radio" name="method" methodname="deposit.gc" value="4" checked="yes">
                  </div>
                  <span class="icon-misc cc2"></span>
                  <div class="desc">
                      <h3 id="deposit_gcLabel">Credit Card
                          <span class="hoverable pull-right icon-question-sign"></span>
                      </h3>

                      <div id="gcInputCard" class="hide">
                          <div class="row-fluid">
                              <label for="gc_card_type" class="span3 form-label">Card type:</label>
                              <select id="gc_card_type" name="gc_card_type" class="span7">
                                  <option value="1" selected="">Visa</option>
                                  <option value="2">American Express</option>
                                  <option value="3">Mastercard</option>
                                  <option disabled="disabled">---------</option>
                                  <option value="111">Delta Online</option>
                                  <option value="122">Visa Electron</option>
                                  <option value="125">JCB</option>
                              </select>
                          </div>
                          <div class="row-fluid">
                              <label for="gc_country_id" class="span3 form-label">Send from:</label>
                              <select id="gc_country_id" name="country_code" class="country_code span7" data-payment_id="deposit.gc">
                                  <option value="AF">Afghanistan</option><option value="AX">Aland Islands</option><option value="AL">Albania</option><option value="DZ">Algeria</option><option value="AS">American Samoa</option><option value="AD">Andorra</option><option value="AO">Angola</option><option value="AI">Anguilla</option><option value="AQ">Antarctica</option><option value="AG">Antigua and Barbuda</option><option value="AR">Argentina</option><option value="AM">Armenia</option><option value="AW">Aruba</option><option value="AU">Australia</option><option value="AT">Austria</option><option value="AZ">Azerbaijan</option><option value="BS">Bahamas</option><option value="BH">Bahrain</option><option value="BD">Bangladesh</option><option value="BB">Barbados</option><option value="BY">Belarus</option><option value="BE">Belgium</option><option value="BZ">Belize</option><option value="BJ">Benin</option><option value="BM">Bermuda</option><option value="BT">Bhutan</option><option value="BO">Bolivia</option><option value="BQ">Bonaire, Saint Eustatius and Saba</option><option value="BA">Bosnia and Herzegovina</option><option value="BW">Botswana</option><option value="BV">Bouvet Island</option><option value="BR">Brazil</option><option value="IO">British Indian Ocean Territory</option><option value="BN">Brunei Darussalam</option><option value="BG">Bulgaria</option><option value="BF">Burkina Faso</option><option value="BI">Burundi</option><option value="KH">Cambodia</option><option value="CM">Cameroon</option><option value="CA">Canada</option><option value="CV">Cape Verde</option><option value="KY">Cayman Islands</option><option value="CF">Central African Republic</option><option value="TD">Chad</option><option value="CL">Chile</option><option value="CN">China</option><option value="CX">Christmas Island</option><option value="CC">Cocos (Keeling) Islands</option><option value="CO">Colombia</option><option value="KM">Comoros</option><option value="CG">Congo</option><option value="CD">Congo, The Democratic Republic of the</option><option value="CK">Cook Islands</option><option value="CR">Costa Rica</option><option value="CI">Cote D'Ivoire</option><option value="HR">Croatia</option><option value="CU">Cuba</option><option value="CW">Curacao</option><option value="CY">Cyprus</option><option value="CZ">Czech Republic</option><option value="DK">Denmark</option><option value="DJ">Djibouti</option><option value="DM">Dominica</option><option value="DO">Dominican Republic</option><option value="EC">Ecuador</option><option value="EG">Egypt</option><option value="SV">El Salvador</option><option value="GQ">Equatorial Guinea</option><option value="ER">Eritrea</option><option value="EE">Estonia</option><option value="ET">Ethiopia</option><option value="FK">Falkland Islands (Malvinas)</option><option value="FO">Faroe Islands</option><option value="FJ">Fiji</option><option value="FI">Finland</option><option value="FR">France</option><option value="GF">French Guiana</option><option value="PF">French Polynesia</option><option value="TF">French Southern Territories</option><option value="GA">Gabon</option><option value="GM">Gambia</option><option value="GE">Georgia</option><option value="DE">Germany</option><option value="GH">Ghana</option><option value="GI">Gibraltar</option><option value="GR">Greece</option><option value="GL">Greenland</option><option value="GD">Grenada</option><option value="GP">Guadeloupe</option><option value="GU">Guam</option><option value="GT">Guatemala</option><option value="GG">Guernsey</option><option value="GN">Guinea</option><option value="GW">Guinea-Bissau</option><option value="GY">Guyana</option><option value="HT">Haiti</option><option value="HM">Heard Island and McDonald Islands</option><option value="VA">Holy See (Vatican City State)</option><option value="HN">Honduras</option><option value="HK">Hong Kong</option><option value="HU">Hungary</option><option value="IS">Iceland</option><option value="IN">India</option><option value="ID">Indonesia</option><option value="IR">Iran, Islamic Republic of</option><option value="IQ">Iraq</option><option value="IE">Ireland</option><option value="IM">Isle of Man</option><option value="IL">Israel</option><option value="IT">Italy</option><option value="JM">Jamaica</option><option value="JP">Japan</option><option value="JE">Jersey</option><option value="JO">Jordan</option><option value="KZ">Kazakhstan</option><option value="KE">Kenya</option><option value="KI">Kiribati</option><option value="KP">Korea, Democratic People's Republic of</option><option value="KR">Korea, Republic of</option><option value="XK">Kosovo</option><option value="KW">Kuwait</option><option value="KG">Kyrgyzstan</option><option value="LA">Lao People's Democratic Republic</option><option value="LV">Latvia</option><option value="LB">Lebanon</option><option value="LS">Lesotho</option><option value="LR">Liberia</option><option value="LY">Libya</option><option value="LI">Liechtenstein</option><option value="LT">Lithuania</option><option value="LU">Luxembourg</option><option value="MO">Macau</option><option value="MK">Macedonia</option><option value="MG">Madagascar</option><option value="MW">Malawi</option><option value="MY">Malaysia</option><option value="MV">Maldives</option><option value="ML">Mali</option><option value="MT">Malta</option><option value="MH">Marshall Islands</option><option value="MQ">Martinique</option><option value="MR">Mauritania</option><option value="MU">Mauritius</option><option value="YT">Mayotte</option><option value="MX">Mexico</option><option value="FM">Micronesia, Federated States of</option><option value="MD">Moldova, Republic of</option><option value="MC">Monaco</option><option value="MN">Mongolia</option><option value="ME">Montenegro</option><option value="MS">Montserrat</option><option value="MA">Morocco</option><option value="MZ">Mozambique</option><option value="MM">Myanmar</option><option value="NA">Namibia</option><option value="NR">Nauru</option><option value="NP">Nepal</option><option value="NL">Netherlands</option><option value="NC">New Caledonia</option><option value="NZ">New Zealand</option><option value="NI">Nicaragua</option><option value="NE">Niger</option><option value="NG">Nigeria</option><option value="NU">Niue</option><option value="NF">Norfolk Island</option><option value="MP">Northern Mariana Islands</option><option value="NO">Norway</option><option value="OM">Oman</option><option value="PK">Pakistan</option><option value="PW">Palau</option><option value="PS">Palestinian Territory</option><option value="PA">Panama</option><option value="PG">Papua New Guinea</option><option value="PY">Paraguay</option><option value="PE">Peru</option><option value="PH">Philippines</option><option value="PN">Pitcairn Islands</option><option value="PL">Poland</option><option value="PT">Portugal</option><option value="PR">Puerto Rico</option><option value="QA">Qatar</option><option value="RE">Reunion</option><option value="RO">Romania</option><option value="RU">Russian Federation</option><option value="RW">Rwanda</option><option value="BL">Saint Barthele my</option><option value="SH">Saint Helena</option><option value="KN">Saint Kitts and Nevis</option><option value="LC">Saint Lucia</option><option value="MF">Saint Martin</option><option value="PM">Saint Pierre and Miquelon</option><option value="VC">Saint Vincent and the Grenadines</option><option value="WS">Samoa</option><option value="SM">San Marino</option><option value="ST">Sao Tome and Principe</option><option value="SA">Saudi Arabia</option><option value="SN">Senegal</option><option value="RS">Serbia</option><option value="SC">Seychelles</option><option value="SL">Sierra Leone</option><option value="SG">Singapore</option><option value="SX">Sint Maarten (Dutch part)</option><option value="SK">Slovakia</option><option value="SI">Slovenia</option><option value="SB">Solomon Islands</option><option value="SO">Somalia</option><option value="ZA">South Africa</option><option value="GS">South Georgia and the South Sandwich Islands</option><option value="ES">Spain</option><option value="LK">Sri Lanka</option><option value="SD">Sudan</option><option value="SR">Suriname</option><option value="SJ">Svalbard and Jan Mayen</option><option value="SZ">Swaziland</option><option value="SE">Sweden</option><option value="CH">Switzerland</option><option value="SY">Syrian Arab Republic</option><option value="TW">Taiwan</option><option value="TJ">Tajikistan</option><option value="TZ">Tanzania, United Republic of</option><option value="TH">Thailand</option><option value="TL">Timor-Leste</option><option value="TG">Togo</option><option value="TK">Tokelau</option><option value="TO">Tonga</option><option value="TT">Trinidad and Tobago</option><option value="TN">Tunisia</option><option value="TR">Turkey</option><option value="TM">Turkmenistan</option><option value="TC">Turks and Caicos Islands</option><option value="TV">Tuvalu</option><option value="UG">Uganda</option><option value="UA">Ukraine</option><option value="AE">United Arab Emirates</option><option value="GB">United Kingdom</option><option value="US">United States</option><option value="UM">United States Minor Outlying Islands</option><option value="UY">Uruguay</option><option value="UZ">Uzbekistan</option><option value="VU">Vanuatu</option><option value="VE">Venezuela</option><option value="VN" selected="">Vietnam</option><option value="VG">Virgin Islands, British</option><option value="VI">Virgin Islands, U.S.</option><option value="WF">Wallis and Futuna</option><option value="EH">Western Sahara</option><option value="YE">Yemen</option><option value="ZM">Zambia</option><option value="ZW">Zimbabwe</option>
                              </select>
                          </div>
                      </div>
                </div>
                <div class="clearfix"></div>
            </li>

            <li id="deposit_paypal_referenceList" class="" style="display: list-item;">
                  <div class="span1 option-radio-container">
                    <input id="deposit.paypal.referenceRadio" type="radio" name="method" methodname="deposit.paypal.reference" value="2">
                  </div>
                  <span class="icon-misc paypal"></span>
                  <div class="desc">
                      <h3 id="deposit.paypal.referenceLabel">Paypal</h3>
                </div>
                <div class="clearfix"></div>
            </li>

            <li id="deposit_moneybookers_onetapList" class="" style=" display: list-item">
                  <div class="span1 option-radio-container">
                    <input id="deposit.moneybookers.onetapRadio" type="radio" name="method" methodname="deposit.moneybookers.onetap" value="3">
                  </div>
                  <span class="icon-misc moneybookers-skrill"></span>
                  <div class="desc">
                      <h3 id="deposit.moneybookers.onetapLabel">Skrill</h3>
                </div>
                <div class="clearfix"></div>
            </li>
        <div class="clearfix"></div>
    </ul>
    <fieldset id="paymentInfo" class="row-fluid">
                    <div class="well">
                        <div class="row">
                            <div class="span4">
                                <label for="depositAmount">I'd like to deposit:</label>
                                <div class="pull-left">
                                    <span id="sign_id_fixed" class="form-prefix">$</span>
                                    <input class="span2" style="height: 27px;" type="text" id="depositAmount" name="amount" value="100" maxlength="15">
                                    <span class="form-label">USD</span>
                                </div>
                            </div>
                            <div class="span3 pull-right">
                                <div class="align-r">
                                    <strong>Amount to Send:<br>
                                        <span id="amountToSendText" class="larger">
                                            <span id="sign_id_send">$</span>
                                            <span class="totalamount" style="display: inline;">100</span>
                                            <span class="totalamount_loading" style="display: none;"><img src="https://cdn3.f-cdn.com/img/ajax-loader.gif?v=62d3d0c60d4c33ef23dcefb9bc63e3a2&amp;m=2" style="padding-bottom: 4px; height: 20px;"></span>
                                            <span id="code_id_send">USD</span>
                                        </span>
                                    </strong><br>
                                    (Balance after deposit:<br>
                                    <strong id="balance"><span id="sign_id_balance">$</span><span id="balance_after_deposit">42.50</span></strong>)
                                </div>
                            </div>
                        </div>
                    </div>
                </fieldset>
            <div class="align-l">
            <button type="button" id="btn_next_id" class="btn btn-primary btn-large">Deposit Money </button>
            </div>
        </form>
    </div>
    <?php
    }
    
    function show_deposit_form_visa_master_card($amount_to_deposit) {
    ?>
            <h1 class="span12">Credit Card Details</h1>
            <div class="col-md-9 ts-well">
                <br/>
                <div class="form-group col-md-4">
                    <label class="ts-pull-left" for="gc_selected_card_type">Card Type:</label>
                    <div class="ts-clear"></div>
                    <select id="gc_selected_card_type" name="gc_card_type" class="form-control pull-left">
                        <option value="1">Visa</option>
                        <option value="3">Mastercard</option>
                    </select>
                    <div class="ts-clear"></div>
                </div>
                <div class="form-group col-md-9">
                    <label class="ts-pull-left" id="LABEL_F1009">Card No.:</label>
                    <div class="ts-clear"></div>
                    <input id="F1009" class="form-control" type="text" name="CREDITCARDNUMBER" size="20" maxlength="19" autocomplete="off" value=""><input id="F1009_OBFUSCATED" class="ORB_INPUT" type="hidden" name="CREDITCARDNUMBER_OBFUSCATED" size="20" maxlength="19" value=""><input id="F1009_CLEAR" class="ORB_INPUT" type="hidden" name="CREDITCARDNUMBER_CLEAR" size="20" maxlength="19" value="">
                    <div class="ts-clear"></div>
                </div>
                <div class="form-group col-md-7">
                    <label class="ts-pull-left" id="LABEL_F1010">Expiration date:</label>
                    <div class="ts-clear"></div>
                    <div class="form-inline ts-pull-left">
                        <select id="F1010_MM" class="form-control" name="EXPIRYDATE_MM">
                            <option value="">Month</option>
                            <option value="01">01</option>
                            <option value="02">02</option>
                            <option value="03">03</option>
                            <option value="04">04</option>
                            <option value="05">05</option>
                            <option value="06">06</option>
                            <option value="07">07</option>
                            <option value="08">08</option>
                            <option value="09">09</option>
                            <option value="10">10</option>
                            <option value="11">11</option>
                            <option value="12">12</option>
                        </select>

                        <select id="F1010_YY" class="form-control" name="EXPIRYDATE_YY">
                            <option value="">Year</option>
                            <option value="14">14</option>
                            <option value="15">15</option>
                            <option value="16">16</option>
                            <option value="17">17</option>
                            <option value="18">18</option>
                            <option value="19">19</option>
                            <option value="20">20</option>
                            <option value="21">21</option>
                            <option value="22">22</option>
                            <option value="23">23</option>
                            <option value="24">24</option>
                            <option value="25">25</option>
                            <option value="26">26</option>
                            <option value="27">27</option>
                            <option value="28">28</option>
                            <option value="29">29</option>
                            <option value="30">30</option>
                            <option value="31">31</option>
                            <option value="32">32</option>
                            <option value="33">33</option>
                            <option value="34">34</option>
                            <option value="35">35</option>
                            <option value="36">36</option>
                            <option value="37">37</option>
                            <option value="38">38</option>
                            <option value="39">39</option>
                        </select>
                        <input id="F1010" type="hidden" name="EXPIRYDATE" value="">
                    </div>
                    <div class="ts-clear"></div>
                </div>
                <div class="form-group col-md-12">
                    <label class="ts-pull-left" id="LABEL_F1136">Security code:</label>
                    <div class="ts-clear"></div>
                    <div class="form-inline ts-pull-left">
                    <input id="F1136" class="form-control" type="text" name="CVV" size="4" maxlength="4" autocomplete="off" value=""><input id="F1136_OBFUSCATED" class="ORB_INPUT" type="hidden" name="CVV_OBFUSCATED" size="4" maxlength="4" value="">
                    <input id="F1136_CLEAR" class="ORB_INPUT" type="hidden" name="CVV_CLEAR" size="4" maxlength="4" value="">
                    <a href="#" class="Normal" onclick="javascript: openCVVHelpWindow('/CVVHelp.jsp;jsessionid=E8441A75E71DA9F78C652A802FE07603'); return false;">What is a security code?</a>
                    </div>
                    <div class="ts-clear"></div>
                </div>
                <div class="form-group col-md-12 gaf-container">
                    <input id="btnSubmit" type="submit" value="Continue" class="form-control ts-pull-left btn btn-primary btn-large" onclick="return onSubmit(false);">
                    <div class="ts-clear"></div>
                    <br/>
                    <p class="ts-pull-left"><small>By clicking 'Continue', you authorize the use of your credit card for this deposit.</small></p>
                    <div class="ts-clear"></div>
                </div>


            </div>
            <div class="gaf-container">
                    <h3 class="ts-distance-left ts-pull-left text-center">Amount to be sent:</h3>
                    <p id="gc_amount_to_deposit" class="ts-distance-left ts-pull-left larger">
                        <span id="sign_id_send">$</span>
                        <span class="totalamount" style="display: inline;"><?php echo $amount_to_deposit; ?></span>
                        <span id="code_id_send">USD</span>
                    </p>
            </div>
    <?php
    }
    
    function show_deposit_form_paypal($amount_to_deposit) {
        lib_session::start_session();
        $username = $_SESSION['user_info']['username'];
        $nvpStr = "&item_name=Deposit for $username&amount_to_deposit=$amount_to_deposit";
        echo lib_http::HttpPost(LINK_ROOT . DIR_PAYMENT_PAYPAL . "paypal.php", $nvpStr);
    }
    
    function show_deposit_form_skrill($amount_to_deposit) {
        lib_session::start_session();
        $username = $_SESSION['user_info']['username'];
        $email = $_SESSION['user_info']['email'];
        $nvpStr = "&product_name=Deposit for $username&amount_to_deposit=$amount_to_deposit&email=$email";
        echo lib_http::HttpPost(LINK_ROOT . DIR_PAYMENT_SKRILL . "skrill.php", $nvpStr);
    }
    
    function show_modal_betting_confirmation($div_id, $ok_click_event) {
    ?>
<!-- Begin Bet Confirm Modal -->
<div id="<?php echo $div_id; ?>" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">Betting Confirmation</h4>
      </div>
      <div class="modal-body">
          <p>PROFIT if win after betting is: 
              <strong id="<?php echo $div_id; ?>_message" style="font-size: 40px;"><!-- ajax loading --></strong>
          </p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
        <button type="button" onclick="<?php echo $ok_click_event; ?>" class="btn btn-primary">Still Bet</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- End Bet Confirm Modal -->
    <?php
    }
    
    function show_profit_text($profit_if_win, $bet_amount, $match_id, $before_betting) {
        $class = '';
        $sign = '';
        $profit_if_win_value = '0';
        $total_if_win_value = round($bet_amount, 2);
        if ($profit_if_win > 0 && !api_bet_calculators::only_one_player_on_match($match_id, $before_betting)) { 
            $class = 'text-success'; 
            $sign = '+';
            $profit_if_win_value = round($profit_if_win, 2);
            $total_if_win_value = round($profit_if_win + $bet_amount, 2);
        }
        
        $profit_if_win_text = $sign . " $ " . $profit_if_win_value;
        $total_if_win_text = "= $ " . $total_if_win_value;
        $result = [
            'profit_if_win_text' => $profit_if_win_text,
            'profit_if_win_value' => $profit_if_win_value,
            'total_if_win_text' => $total_if_win_text,
            'total_if_win_value' => $total_if_win_value,
            'class' => $class,
        ];
        return $result;
    }